package com.qf.servlet;

import com.qf.pojo.Product;
import com.qf.service.ProductService;
import com.qf.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/index")
public class IndexServlet extends baseServlet {
    //查询最新商品
   public void index(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
       //调用业务层
       ProductService productService = new ProductServiceImpl();
       //获取最新商品列表
       List<Product> newList = productService.findProduct();
         //获取最热商品列表
       List<Product> hotList = productService.hotProduct();
            //将两个集合存储到request中
           request.setAttribute("newList",newList);
           request.setAttribute("hotList",hotList);
           request.getRequestDispatcher("/jsp/index.jsp").forward(request,response);

   }
}
